package DimensionGui;
import java.awt.Scrollbar;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;

public class MyIncrementerScroll implements AdjustmentListener {

	TextboxScrollBar _parent;
	int _currLocation;

	// ScrollBar its listening on

	public MyIncrementerScroll(TextboxScrollBar parent) {
		_parent = parent;
		_currLocation = _parent.getValue();
	}

	@Override
	public void adjustmentValueChanged(AdjustmentEvent arg0) {
		// up or down?
		int _newLoc = _parent.getValue();

		if (_newLoc < _currLocation) {
			System.out.println("goin up");
			// increment up
			 _parent.IncrementUp();

		}
		if (_newLoc > _currLocation) {
			System.out.println("goin Down");
			// increment up
			_parent.IncrementDown();

		}

		// check bounds, should never happen, bats it back when user gets close

		if (_newLoc - 100 < _parent.getMinimum()) {
			_newLoc = _newLoc + 1000;
			_parent.setValue(_newLoc);

		} else if (_newLoc + 100 > _parent.getMaximum()) {
			_newLoc = _newLoc - 1000;
			_parent.setValue(_newLoc);
		}

		System.out.println(arg0.getValue());
		// TODO Auto-generated method stub

		_currLocation = _newLoc;
	}
}
